package client;

public class Signal {
    private String signal;
    public boolean validitaPrikazu = false;
    private Prikaz druhPrikazu;
    protected String stav = "ok";

    public Signal(String signal) {
        this.signal = signal;
        zpracujPrikaz();
    }

    public byte[] prikazByte() {
        if(validitaPrikazu) {
            byte[] vystup = new byte[0];

            return vystup;
        }
        else
            throw new IllegalArgumentException("\n" + signal + "\nDůvod: " + stav + "\n");
    }

    public String prikazString() {
        return "";
    }

    private void zpracujPrikaz() {
        try {
            String[] prikaz = signal.split(":");
            druhPrikazu = new Prikaz(prikaz[0], signal.replace(prikaz[0] + ":\n", ""), this);
        }
        catch (Exception e) { validitaPrikazu = false; }
    }
}
